import request from '@/utils/request';
import { OrderQuery, OrderVO, OrderForm } from './types';
import { AxiosPromise } from 'axios';

// 查询订单列表
export function listOrder(query: OrderQuery): AxiosPromise<any> {
  return request({
    url: '/order/order/list',
    method: 'get',
    params: query
  });
}

// 查询订单列表（不分页）
export function listOrderAll(query: OrderQuery): AxiosPromise<OrderVO[]> {
  return request({
    url: '/order/order/listOrder',
    method: 'get',
    params: query
  });
}

// 查询订单详细
export function getOrder(id: string | number): AxiosPromise<OrderVO> {
  return request({
    url: '/order/order/' + id,
    method: 'get'
  });
}

// 新增订单
export function addOrder(data: OrderForm) {
  return request({
    url: '/order/order',
    method: 'post',
    data: data
  });
}

// 修改订单
export function updateOrder(data: OrderForm) {
  return request({
    url: '/order/order',
    method: 'put',
    data: data
  });
}

// 删除订单
export function delOrder(ids: string | number | Array<string | number>) {
  return request({
    url: '/order/order/' + ids,
    method: 'delete'
  });
}

// 获取今日订单数
export function getTodayOrderCount() {
  return request({
    url: '/order/order/today/count',
    method: 'get'
  });
}

// 获取今日销售额
export function getTodaySales() {
  return request({
    url: '/order/order/today/sales',
    method: 'get'
  });
}
